Skip to main content

All Questions

0votes
1answer
149views

How can root get access to SSH_TTY

I think that SSH_TTY is an environment variable set by ssh that holds the device node of the current virtual terminal; e.g. /dev/pts/0, /dev/pts/1 , etc. I know that when I'm logged in to an SSH ...
Seamus's user avatar
  • 3,727
1vote
2answers
165views

Multiple ssh sessions with different users

I am writing a script that connects to multiple servers which uses 3 different users. #!/bin/ksh server1=("abc1" "abc2") server2=("abc3" "abc4") server3=("...
NecroCoder's user avatar
4votes
3answers
552views

Two ssh output as awk input

I have two remote servers that I am trying to ssh and cat some files.. I want to input the output of the ssh to a awk command. This is what I have got ssh username@host1 “cat /tmp/test/*” ssh ...
NecroCoder's user avatar
0votes
0answers
653views

writing a private key from a variable to file [duplicate]

I have a scenario where I am exporting private key and writing it to a file. export CLI_KEY_FILE="-----BEGIN PRIVATE KEY----- 3MFPAZh1qa8XsLdlBBwRypZ8QxTzjdYe4trERoWoLMuaZWsAVRzTypCZG0/Hhfin ...
Jenifer's user avatar
0votes
1answer
1kviews

How to suspend a SSH session using Ctrl+Z in shell script?

I have a shell script that executes on remote server through ssh. It needs to execute Ctrl+Z and background the shell session to temporarily be back to my local terminal. I tried for the following ...
tipotto's user avatar
2votes
1answer
494views

unable to expand the variables inside ssh

I'm trying to search for the file of the format : "installation_xx_int_${type}_*log" of the current date inside the remote server using below command: ssh user@hostname 'file=$(find ~ -type ...
ashish_k's user avatar
1vote
2answers
128views

Can I pass a variable from case statement out of SSH session?

Let's say there is a case statement within the SSH session. I want to pass the variable entry out of remote machine and store it in local machine's csv file. The example: #!/bin/sh set -x read -p ...
TensorFlowGuan's user avatar
0votes
1answer
776views

Run a IF statement inside a for loop with ssh

I have two pieces of code that work independently, but not together. I need to put the if statement inside the <Command_To_Be_Ran>. Any ideas to how i can get this to work? for i in t{1..2}; do ...
TrevorKS's user avatar
0votes
1answer
144views

Shell Script that create log if file is not send to remote server

I have this small script which basically do rsync of files between to remote server. ssh key has been generated for authentication. only this is present in the script rsync /root/Desktop/cpfies/...
user avatar
2votes
2answers
4kviews

How to ssh and run multiple commands wrapped in if else?

I wanted to capture some data from various servers using ssh and run some commands with some conditions. I don't want to do: if ssh $host test -f /file; then # If file exists var=$(ssh $host ...
annahri's user avatar
  • 2,126
5votes
1answer
13kviews

how can I execute command through ssh, remote is windows

My remote machine is a windows and I am doing ssh from ubuntu to windows. I want to use git bash instead of command prompt, but running the ssh will bring me to the default command prompt, is there ...
Tiger's user avatar
2votes
2answers
3kviews

SSH process won't end when I run a background command on remote host

I am running the following SSH command: ssh "root@$ip" 'nohup sh -s' < ./do_sync & My goal is to execute the contents of do_sync (a shell script) on the remote host. I'm doing it this way ...
void.pointer's user avatar
1vote
2answers
321views

Remote SSH command is not working in Function

I am trying to set group permission on directories in remote instances using a function which will take input of directory and group and the function is as below total there are three instances of ...
Rahul's user avatar
0votes
1answer
1kviews

Passing comma separated variable to remote SSH Session

I am trying to read comma separated variable in shell script and splitting it like as below while [ -z "$variable" ] do printf 'variable: ' read -r variable [ -z "$variable" ] &...
Rahul's user avatar
1vote
2answers
459views

Persist SSH Command

First off, I know about tmux and screen. My conundrum: I started a shell script over SSH expecting it would take a short amount of time, so I left my computer on overnight. I can't terminate and ...
Jared Nielsen's user avatar

153050per page
close